Skip to content

Conversation

pabloerhard
Copy link

@pabloerhard pabloerhard commented Oct 2, 2025

This PR adds compatibility with specifiers, for example:

module.exports = require('#main-entry-point');

These specifiers are defined inside the package.json file and can reference either a local file or an external module.

The proposed solution works as follows: whenever a require call begins with # (all specifiers must start with #), locates the package.json, extracts the corresponding reference from the imports field, and sets the newUrl with the resolved path, maintains any original process after that.

jsumners-nr
jsumners-nr previously approved these changes Oct 2, 2025
Copy link
Contributor

@jsumners-nr jsumners-nr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable with linting fixed.

@pabloerhard pabloerhard force-pushed the pabloerhard/fix-to-specifier-imports branch from 21de0c1 to a153042 Compare October 2, 2025 15:59
timfish
timfish previously approved these changes Oct 3, 2025
@timfish timfish changed the title Added compatibility for specifier imports feat: Specifier imports compatibility Oct 3, 2025
@timfish timfish changed the title feat: Specifier imports compatibility feat: Compatibility with specifier imports Oct 3, 2025
@timfish timfish requested a review from bengl October 4, 2025 10:11
AbhiPrasad
AbhiPrasad previously approved these changes Oct 5, 2025
return null
}
}
} catch (error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} catch (error) {
} catch {

Alternatively, we could also just add the cause

@pabloerhard pabloerhard force-pushed the pabloerhard/fix-to-specifier-imports branch from 3a000d2 to 1f7a010 Compare October 6, 2025 21:20
@pabloerhard pabloerhard force-pushed the pabloerhard/fix-to-specifier-imports branch from 1f7a010 to 2022e5e Compare October 7, 2025 02:08
timfish
timfish previously approved these changes Oct 7, 2025
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, while I think we should add the cause to the error we create in the catch clause.

@pabloerhard
Copy link
Author

LGTM, while I think we should add the cause to the error we create in the catch clause.

Completely missed this, should I go ahead and add it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants